package com.ysucode.dao.user;

import com.ysucode.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper //告诉spring这个接口是mybatis动态代理生成实现类
public interface UserMapper {

    @Select("select * from auth_user where username = #{username} and password = #{password}")
    User getByUsernamePassword(@Param("username") String username, @Param("password") String password);

    @Select("select * from auth_user where username = #{username}")
    User getByUsername(@Param("username") String username);

    @Insert("insert into auth_user values(null,#{username},#{password},#{email},#{role_id})")
    Integer addUser(User user);

    @Select("select max(id) from auth_user")
    Integer getByLastOfId();

    @Select("select * from auth_user where id = #{id}")
    User getById(@Param("id") int id);
}
